package com.xy.framework;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xy.framework.util.HttpUtils;

public class Haha {

	/**
	 * pageNum 1 numPerPage 20 startCity 郑州 endCity 濮阳 seatNum 1 goTime null
	 * lastId null
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			// System.out.println(HttpUtils.doPost("http://127.0.0.1:99/basics/rest/login",
			// "utf-8"));
			List<NameValuePair> urlParameters = new ArrayList<>();
			urlParameters.add(new BasicNameValuePair("pageNum", "1"));
			urlParameters.add(new BasicNameValuePair("numPerPage", "100"));
			urlParameters.add(new BasicNameValuePair("startCity", "郑州"));
			urlParameters.add(new BasicNameValuePair("endCity", "新密"));
			urlParameters.add(new BasicNameValuePair("seatNum", "1"));
			urlParameters.add(new BasicNameValuePair("goTime", "null"));
			urlParameters.add(new BasicNameValuePair("lastId", "null"));
			String str = HttpUtils.doPost("http://hh.hnxzkj.cn/WebApp/Home/GetAssList", "utf-8",urlParameters);
			// System.out.println(HttpUtils.doPost("http://hh.hnxzkj.cn/WebApp/Home/GetAssList",
			// "utf-8"));
			JSONObject jo = JSONObject.parseObject(str);
			JSONArray array = new JSONArray();
			List l = new ArrayList<>();
			l = (List) array.toJSON(jo.get("DataSource"));
			for (int i = 0; i < l.size(); i++) {
				System.out.println(l.get(i));
				JSONObject jo3 = JSONObject.parseObject(l.get(i).toString());
				// System.out.println(jo3.get("Remark"));
				String str1 = (String) jo3.get("Remark");
					System.out.println(filterEmoji(str1));
			}
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		// TODO Auto-generated method stub
	}

	public static String filterEmoji(String source) {
		if (source != null) {
			Pattern emoji = Pattern.compile("[\ud83c\udc00-\ud83c\udfff]|[\ud83d\udc00-\ud83d\udfff]|[\u2600-\u27ff]",
					Pattern.UNICODE_CASE | Pattern.CASE_INSENSITIVE);
			Matcher emojiMatcher = emoji.matcher(source);
			if (emojiMatcher.find()) {
				source = emojiMatcher.replaceAll("*");
				return source;
			}
			return source;
		}
		return source;
	}
}
